<?php
/**
 * @package		Joomla.Site
 * @subpackage	com_search
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access
defined('_JEXEC') or die;

jimport('joomla.application.component.view');

/**
 * HTML View class for the search component
 *
 * @static
 * @package		Joomla.Site
 * @subpackage	com_search
 * @since 1.0
 */
class NewsViewCareer extends JView
{
	function display($tpl = null)
	{				
		$pages = JRequest::getVar('page');		
		switch($pages){
			case 'detail':
				$this->showdetail();
			break;
			default:
				$this->showCareerHip();
			break;
		}
	}
	public function showdetail(){
		$app = JFactory::getApplication();						
		$my = JFactory::getUser();
		$scat = JRequest::getVar('scat', 0);	
		$id = JRequest::getVar('id', 0);	
		$model		= $this->getModel();
		/*if ($layout == 'employer'){
			$newsdetail = $model->latestNewsById( $scat, $id );	
		}else{
			$newsdetail = $model->latestNewsById( $scat, $id );	
		}*/	
		$newsdetail = $model->latestNewsById( $scat, $id );	
		
		Career::showDetailCareer($newsdetail);
	}
	function showCareerHip($tpl = null){				
		$app = JFactory::getApplication();						
		$my = JFactory::getUser();
		$value = $app->getUserStateFromRequest( 'list_limit', 'limit', $app->getCfg('list_limit'), 'int' );
		$start = $app->getUserStateFromRequest( 'limitstart', 'limitstart', 0, 'int' );		
		$scat = JRequest::getVar('scat', 0);
		$catid = JRequest::getVar('catid', 0);
		//$catid = JRequest::getVar('catid', 0);
		
		$model		= $this->getModel();	
		if ( !$scat ){
			$scat = $model->getDefaultCat( $catid );		
		}		
		$layout = JRequest::getVar('layout');
		$latestnews = $model->latestHip( $scat );
		
		$listnews 	= $model->listNews($start,$value, $scat );			
		$total		= $model->listNewsTotal( $latestnews->id, $scat );	
		
		jimport('joomla.html.pagination');
		$pagination = new JPagination( $total, $start, $value );
		
		$this->assign('scat',			$scat);
		$this->assign('catid',			$catid);
		$this->assign('latestnews',		$latestnews);
		$this->assign('listnews',		$listnews);
		$this->assign('pagination',		$pagination);		
		
		parent::display($tpl);
	}
	public function &getModel($name = 'career', $prefix = '', $config = array('ignore_request' => true))
	{
		$model = parent::getModel($name, $prefix, $config);

		return $model;
	}
}
